<template>
  <div class="app-container">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <el-row>
          <el-form
            :inline="true"
            :model="listQuery"
            ref="dataList2"
            class="demo-form-inline"
          >
            <el-form-item label="用户Id">
              <el-input
                v-model.number="listQuery.user_code"
                placeholder="用户编号"
                clearable
              ></el-input>
            </el-form-item>
            <el-form-item label="签到天数">
              <el-input
                v-model.number="listQuery.days"
                placeholder="签到天数"
                clearable
              ></el-input>
            </el-form-item>

            <el-form-item>
              <el-button type="primary" @click="searchSubmit">查询</el-button>
              <el-button type="primary" @click="handleRsetSubmit"
                >重置</el-button
              >
            </el-form-item>
          </el-form>
        </el-row>
      </div>
      <div class="item">
        <el-table :data="data" border>
          <el-table-column
            prop="id"
            label="序号"
            width="150px"
          ></el-table-column>
          <el-table-column prop="nickname" label="用户昵称"></el-table-column>
          <el-table-column prop="user_code" label="用户Id"> </el-table-column>
          <el-table-column prop="days" label="签到时长/天"> </el-table-column>
          <el-table-column prop="remark" label="领取内容"></el-table-column>
          <el-table-column prop="add_time" label="领取时间"> </el-table-column>
        </el-table>
        <!-- 分页 -->
        <cus-pagination
          :total="total"
          :page.sync="listQuery.page"
          :limit.sync="listQuery.perPage"
          @pagination="getList"
        />
      </div>
    </el-card>
  </div>
</template>

<script>
import { toGetSignLog } from "@/api/dailyCheck/dailyCheck";
export default {
  data() {
    return {
      data: [],
      listQuery: {
        page: 1,
        perPage: 10,
        days: undefined,
        user_code: undefined
      },
      total: 0
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 点击查询
    searchSubmit() {
      this.listQuery.page = 1;
      this.getList();
    },
    // 点击重置
    handleRsetSubmit() {
      this.listQuery.page = 1;
      this.listQuery.perPage = 10;
      this.listQuery.days = undefined;
      this.listQuery.user_code = undefined;
      this.getList();
    },
    getList() {
      toGetSignLog(this.listQuery).then(response => {
        console.log(response, "res");
        this.data = response.data.list;
        this.total = response.data.meta.total;
      });
    }
  }
};
</script>

<style lang="scss" scoped></style>
